package org.linlinjava.litemall.admin.vo.hospital_send;

import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.linlinjava.litemall.db.vo.shop.HospitalSendDto;
import org.linlinjava.litemall.db.vo.shop.HospitalSendTimePeriodDto;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author wj
 * @date 2021/12/7 10:06
 */
public class HospitalSendDeliveryTypeVo {

    @NotNull(message = "加急费用不能为空")
    private BigDecimal urgentCost;

    @NotNull(message = "加急时间不能为空")
    private Integer deliveryTime;

    @NotNull(message = "店铺id不能为空")
    private Integer shopId;

    private Integer onlyToHospital;

    private Integer subscribeDay;

    private Integer hourReach;

    private Integer subscribe;

    private List<HospitalSendTimePeriodDto> timePeriods;

    public HospitalSendDeliveryTypeVo(BigDecimal urgentCost, Integer deliveryTime, Integer shopId, Integer onlyToHospital, Integer subscribeDay, Integer hourReach, Integer subscribe, List<HospitalSendTimePeriodDto> timePeriods) {
        this.urgentCost = urgentCost;
        this.deliveryTime = deliveryTime;
        this.shopId = shopId;
        this.onlyToHospital = onlyToHospital;
        this.subscribeDay = subscribeDay;
        this.hourReach = hourReach;
        this.subscribe = subscribe;
        this.timePeriods = timePeriods;
    }


    public HospitalSendDeliveryTypeVo(HospitalSendDto hospitalSendDto) {
        this.urgentCost = hospitalSendDto.getUrgentCost();
        this.deliveryTime = hospitalSendDto.getDeliveryTime();
        this.shopId = hospitalSendDto.getBusiId();
        this.onlyToHospital = hospitalSendDto.getOnlyToHospital();
        this.subscribeDay = hospitalSendDto.getSubscribeDay();
        this.hourReach = hospitalSendDto.getHourReach();
        this.subscribe = hospitalSendDto.getSubscribe();
        if (StringUtils.isNotEmpty(hospitalSendDto.getTimePeriod())) {
            this.timePeriods = JSON.parseArray(hospitalSendDto.getTimePeriod(), HospitalSendTimePeriodDto.class);
        }
        else{
            this.timePeriods =null;
        }
    }

    public HospitalSendDeliveryTypeVo() {
    }

    public BigDecimal getUrgentCost() {
        return urgentCost;
    }

    public void setUrgentCost(BigDecimal urgentCost) {
        this.urgentCost = urgentCost;
    }

    public Integer getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(Integer deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public Integer getShopId() {
        return shopId;
    }

    public void setShopId(Integer shopId) {
        this.shopId = shopId;
    }

    public Integer getOnlyToHospital() {
        return onlyToHospital;
    }

    public void setOnlyToHospital(Integer onlyToHospital) {
        this.onlyToHospital = onlyToHospital;
    }

    public Integer getSubscribeDay() {
        return subscribeDay;
    }

    public void setSubscribeDay(Integer subscribeDay) {
        this.subscribeDay = subscribeDay;
    }

    public Integer getHourReach() {
        return hourReach;
    }

    public void setHourReach(Integer hourReach) {
        this.hourReach = hourReach;
    }

    public Integer getSubscribe() {
        return subscribe;
    }

    public void setSubscribe(Integer subscribe) {
        this.subscribe = subscribe;
    }

    public List<HospitalSendTimePeriodDto> getTimePeriods() {
        return timePeriods;
    }

    public void setTimePeriods(List<HospitalSendTimePeriodDto> timePeriods) {
        this.timePeriods = timePeriods;
    }
}
